<style>
table.lo * { font-size: 12px; font-family: Trebuchet MS; }
table.lo { width: 100%; }
table.lo td { vertical-align: top; text-align: left; }
table.lo td.leftbar { width: 230px; vertical-align: top; }
table.lo td.content { vertical-align: top; overflow-x: hidden; height: 50px; }
.pure_form_extra { background: #fff; padding: 10px; border: 1px solid #aaa; border-radius: 8px; font-size: 12px; }
.ui-state-error * { font-size: 14px !important; }

</style>

<?php
$inc = Utils::get_param('inc', 'status');
$type = Utils::get_param('type', 0);
if (isset($_SESSION['user'])) {
  $user = json_decode($_SESSION['user']);
  
  $opts = new stdClass();
  $opts->cd = 't.customer_id = :v1';
  $opts->cdv = array(':v1' => $user->id);
  $opts->sel = 't.is_paid, t.ship_date, t.is_cancel';
  $rslt = $orm->get('pb_ecom_order', NULL, NULL, NULL, NULL, $opts)->d;
  
  $unpaid = 0;
  $shipped = 0;
  $paid = 0;
  $cancelled = 0;
  
  foreach ($rslt as $itm) {
    if ($itm->is_cancel == 1) {
      $cancelled++;
    } else if ($itm->is_cancel == 0 && $itm->is_paid == 0) {
      $unpaid++;
    } else if ($itm->is_cancel == 0 && $itm->is_paid == 1 && $itm->ship_date == '0000-00-00') {
      $paid++;
    } else if ($itm->is_cancel == 0 && $itm->ship_date != '0000-00-00') {
      $shipped++;
    }
  }
}
?>

<?php if (isset($_SESSION['user'])) { ?>
<table class="lo" cellPadding=0 cellSpacing=0>
  <tr>
    <td class="leftbar"><?php include dirname(__FILE__) . '/inc.leftbar.php'; ?></td>
    <td class="content">
      <?php if ($unpaid > 0) {?>
      <div class="ui-state-error ui-corner-all" style="padding: 5px 10px;">
        <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
        <strong>注意：</strong> 您有&nbsp;<?php echo $unpaid; ?>&nbsp;个订单还未支付。请尽快<a href="#">支付</a>，否则订单会被取消</p>
        <div style="font-size: 12px !important; padding-top: 5px; padding-left: 15px;">如果您已经银行转账，请不用管这条信息</div>
      </div>
      <div>&nbsp;</div>
      <?php } ?>
      <?php include dirname(__FILE__) . '/inc.' . $inc . '.php'; ?>
    </td>
  </tr>
</table>
<?php } else { ?>
<div class="pure-form pure-form-aligned pure_form_extra">转到登录页面...</div>
<script type="text/javascript">
var __url = '<?php echo URL . HOME_DIR . $app_data->sys->php_name . '.php?i=' . $app_data->__login_id . '&u=' . urlencode(Utils::get_url()); ?>';
if (parent != window) {
  parent.location.href = __url;
} else {
  location.href = __url;
}
</script>
<?php } ?>